Skip to content

Add per-element thresholds to adaptive zoom#409

Open
ayolab wants to merge 4 commits into
mainfrom
ayolab/add-per-element-thresholds-to-adaptive-zoom
Open

Add per-element thresholds to adaptive zoom#409
ayolab wants to merge 4 commits into
mainfrom
ayolab/add-per-element-thresholds-to-adaptive-zoom

Conversation

@ayolab

@ayolab ayolab commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • A PR or issue has been opened in all impacted repositories (if any)

Does this PR already have an issue describing the problem?

No

What kind of change does this PR introduce?

This adds independent thresholds for edge side labels (edgeInfo1/edgeInfo2), the edge middle label, and the edge middle arrow (edgeInfoMiddle), so each can fade out at its own zoom level for smoother large-network rendering.

What is the current behavior?

Adaptive zoom used a single threshold to remove/recreate legends, edge infos and text nodes all at once.

What is the new behavior (if this is a feature change)?
Independent thresholds so each element can be added at its own zoom level for smoother large-network rendering.

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Group all adaptive zoom options into a single adaptiveTextZoom object on NadViewerParametersOptions (enabled, threshold, edgeSideLabelThreshold, edgeMiddleLabelThreshold, edgeMiddleArrowThreshold), replacing the previous flat options enableAdaptiveTextZoom and adaptiveTextZoomThreshold

Other information:

Signed-off-by: Ayoub LABIDI <ayoub.labidi@protonmail.com>
Signed-off-by: Ayoub LABIDI <ayoub.labidi@protonmail.com>
@ayolab ayolab requested a review from rolnico June 11, 2026 10:18
rolnico
rolnico previously approved these changes Jun 12, 2026
return {
enabled: adaptiveTextZoom?.enabled ?? NadViewerParameters.ENABLE_ADAPTIVE_ZOOM_DEFAULT,
threshold: adaptiveTextZoom?.threshold ?? NadViewerParameters.THRESHOLD_ADAPTIVE_ZOOM_DEFAULT,
edgeSideLabelThreshold:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if adaptiveTextZoom?.edgeSideLabelThreshold not defined maybe set to adaptiveTextZoom?.threshold to keep previous usage of one threshold only

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

edgeMiddleLabelThreshold:
adaptiveTextZoom?.edgeMiddleLabelThreshold ?? NadViewerParameters.THRESHOLD_ADAPTIVE_ZOOM_DEFAULT,
edgeMiddleArrowThreshold:
adaptiveTextZoom?.edgeMiddleArrowThreshold ?? NadViewerParameters.THRESHOLD_ADAPTIVE_ZOOM_DEFAULT,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
adaptiveTextZoom?.edgeMiddleArrowThreshold ?? NadViewerParameters.THRESHOLD_ADAPTIVE_ZOOM_DEFAULT,
adaptiveTextZoom?.edgeMiddleArrowThreshold ?? NadViewerParameters.THRESHOLD_ADAPTIVE_TEXT_ZOOM_DEFAULT,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The const was already named like that, I preferred not to rename it, there is some work left to do on naming in general not just here, I think we should do it in a separate PR

}
}
}
for (const edge of edges) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (const edge of edges) {
if (maxDisplayedSize > adaptiveTextZoom.edgeMiddleLabelThreshold) {
for (const edge of edges) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworked this part to do only one loop and I added the check for middleEdgeInfos

Comment on lines 2434 to 2441
this.redrawMiddleEdgeArrowAndLabels(
halfEdge1,
halfEdge2,
edgeInfo,
edgeInfoMetadata.direction ?? edgeInfoMetadata.directionB,
edgeInfoMetadata.directionA,
edgeInfoMetadata.labelA !== undefined && edgeInfoMetadata.labelB !== undefined
showLabel && edgeInfoMetadata.labelA !== undefined && edgeInfoMetadata.labelB !== undefined
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manage case of calling redrawMiddleEdgeArrowAndLabels with showArrow=false ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not call if both showLabel and showArrow are false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the check on the direction to avoid doing extra work for nothing when showArrow is false
but the other case when showLabel and showArrow are false is already covered, we don't even reach this part of the code

@rolnico rolnico dismissed their stale review June 12, 2026 10:36

Some new comments have to be taken into account

Signed-off-by: Ayoub LABIDI <ayoub.labidi@protonmail.com>
@ayolab ayolab requested review from rolnico and sBouzols June 12, 2026 11:36
Signed-off-by: Ayoub LABIDI <ayoub.labidi@protonmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@sBouzols sBouzols left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review OK
Tests in demo app OK
Tests in GridSuite OK
Console warning check OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants